﻿<?php

namespace app\index\server;

use app\common\logic\OrderLogic;
use app\index\controller\Common;
use think\Controller;

class OrderServer extends Common
{
    /**
     * 获取订单详情
     */
    public function getOrderDetail($map)
    {
        halt($map);
        $Order = new OrderLogic;
        $list = $Order->getListNpg($map, $this->order,'');

        halt($list);
//        return json_encode($list);
        //halt($list);exit();
        $lists = array();
        foreach ($list as $k => $v) {
            $lists[$k]['id'] = $v['id'];
            $lists[$k]['or_status'] = $v['or_status'];
//            $totals = $this->orderTotalById($v['id']);
//            $lists[$k]['total'] = $totals[0];
//            $lists[$k]['take_fee'] = $totals[1];
//            $lists[$k]['all_num'] = $totals[2];
            $lists[$k]['detail'] = model('OrderDetail')->where('or_id',$v['id'])->order('id', 'desc')->select();
            //$lists[$k]['st_name'] = model('User')->where('id',$v['st_id'])->value('us_apply_shopname')?:'草津堂';
            $detail = $lists[$k]['detail'];
            foreach ($detail as $key => $value) {

                $detail[$key]['or_pd_pic'] = $value['or_pd_pic']; //商品主图
                $detail[$key]['or_pd_price'] = $value['or_pd_price']; //商品价格
                $detail[$key]['or_rebate'] = $value['or_rebate']; //旧电视抵扣价
                $detail[$key]['or_pd_total'] = $value['or_pd_total']; //成交价
                $detail[$key]['or_pd_content'] = $value['or_pd_content']; //商品描述

//                if(!$pics[0]){
//                    array_shift($pics);
//                }
                //$lists[$k]['detail'][$key]['or_pd_pic'] = $pics;
                // $lists[$k]['detail'][$key]['pd_head_pic'] = model('product')->where('id',$value['pd_id'])->value('pd_head_pic');
            }
        }
//        halt($lists);exit();
        if(!$list){
            $this->result('',0,'没有查询到订单','json');

        }
        return $lists;


    }

}